<?php

namespace App\Controller\Shop;

use App\Model\PssModel\MerchantBuyer;
use App\Service\Code\Normal;
use Hyperf\HttpServer\Contract\RequestInterface;

class MerchantBuyerController extends AbstractController
{
    /**
     * 获取订购人信息列表
     * @param RequestInterface $request
     * @return array
     */
    public function index(RequestInterface $request)
    {
        $binfo = $request->getAttribute('param')['binfo'];
        $body  = $request->getAttribute('param')['body'];
        return MerchantBuyer::instance()->getBuyerInfoList([
            'binfo' => $binfo,
            'body'  => array_merge($body,['is_cut_id_card'=>1])
        ]);
    }

    /**
     * 添加新的订购人信息
     * @param RequestInterface $request
     * @return array
     */
    public function insert(RequestInterface $request)
    {
        $binfo = $request->getAttribute('param')['binfo'];
        $body  = $request->getAttribute('param')['body'];
        return MerchantBuyer::instance()->checkAddUserBuyerInfo($binfo,$body);
    }

    /**
     * 添加新的订购人信息
     * @param RequestInterface $request
     * @return array
     */
    public function update(RequestInterface $request)
    {
        $binfo = $request->getAttribute('param')['binfo'];
        $body  = $request->getAttribute('param')['body'];
        return MerchantBuyer::instance()->checkUpdateUserBuyerInfo($binfo,$body);
    }

    /**
     * 添加新的订购人信息
     * @param RequestInterface $request
     * @return array
     */
    public function delete(RequestInterface $request)
    {
        $binfo = $request->getAttribute('param')['binfo'];
        $body  = $request->getAttribute('param')['body'];
        return MerchantBuyer::instance()->checkDelUserBuyerInfo($binfo,$body);
    }

}